71556f7929895fe583a695bb5dc07f0e2226af08,library/src/main/java/it/michelelacorte/androidshortcuts/ShortcutsCreation.java,ShortcutsCreation,createShortcutsBasedOnGridSize,#number#number#number#GridSize#number#Shortcuts#,360
Before Change
if ((toolbarHeight = Utils.getToolbarHeight(activity)) > 0) {
int maxYScreenWithToolbar = maxYScreen - toolbarHeight * 2;
positionInGrid = ((GridView) gridView).pointToPosition((int) currentXPosition, (int) currentYPosition);
positionInGrid /= gridSize.getColumnCount();
mIconHeight = Math.round(displayDensity * rowHeight) * positionInGrid + 1;
if (mIconHeight + layoutHeightTotal > maxYScreenWithToolbar) {
//Alto
switch (maxXScreen){
case 720:
switch (shortcuts.length){
case 2:
if (i >= 1) {
layout[i].setY(+layoutHeightTotal + mIconHeight / 5 + toolbarHeight * 2 - 75);
} else {
layout[i].setY(+layoutHeightTotal + mIconHeight / 5 + toolbarHeight * 2 + 20);
}
triangle.setY(+layoutHeightTotal + mIconHeight / 5 + toolbarHeight * 2 + 94);
break;
case 3:
layout[i].setY(+layoutHeightTotal + mIconHeight / 5 + toolbarHeight * i - 95);
triangle.setY(+layoutHeightTotal + mIconHeight / 5 + toolbarHeight * i - 23);
break;
case 4:
layout[i].setY(+layoutHeightTotal + mIconHeight / 5 + toolbarHeight * i - 275);
triangle.setY(+layoutHeightTotal + mIconHeight / 5 + toolbarHeight * i - 200);
break;
case 5:
layout[i].setY(+layoutHeightTotal + mIconHeight / 5 + toolbarHeight * i - 475);
triangle.setY(+layoutHeightTotal + mIconHeight / 5 + toolbarHeight * i - 400);
break;
default:
Log.e(TAG, "Invalid numbers of shortcuts! Max is 5");
break;
}
triangle.setRotation(0);
break;
case 1080:
switch (shortcuts.length){
case 2:
if (i >= 1) {
layout[i].setY(+layoutHeightTotal + mIconHeight / 5 - 160 + toolbarHeight * 2);
} else {
layout[i].setY(+layoutHeightTotal + mIconHeight / 5 + toolbarHeight * 2);
}
triangle.setY(+layoutHeightTotal + mIconHeight / 5 + toolbarHeight * 2 + 120);
break;
case 3:
layout[i].setY(+layoutHeightTotal + mIconHeight / 5 - 180 + toolbarHeight * i);
triangle.setY(+layoutHeightTotal + mIconHeight / 5 + 140 * i);
break;
case 4:
layout[i].setY(+layoutHeightTotal + mIconHeight / 5 - 160 * 3 + toolbarHeight * i);
triangle.setY(+layoutHeightTotal + mIconHeight / 5 - 177 * 2 + toolbarHeight * i);
break;
case 5:
layout[i].setY(+layoutHeightTotal + mIconHeight / 5 - 160 * 5 + toolbarHeight * i);
triangle.setY(+layoutHeightTotal + mIconHeight / 5 - 337 * 2 + toolbarHeight * i);
break;
default:
Log.e(TAG, "Invalid numbers of shortcuts! Max is 5");
break;
}
triangle.setRotation(0);
break;
case 1440:
switch (shortcuts.length){
case 2:
if (i >= 1) {
layout[i].setY(+layoutHeightTotal + mIconHeight / 5 - 220 + toolbarHeight * 2);
} else {
layout[i].setY(+layoutHeightTotal + mIconHeight / 5 + toolbarHeight * 2);
}
triangle.setY(+layoutHeightTotal + mIconHeight / 5 + toolbarHeight * 2 + 160);
break;
case 3:
layout[i].setY(+layoutHeightTotal + mIconHeight / 5 - 220 + toolbarHeight * i);
triangle.setY(+layoutHeightTotal + mIconHeight / 5 + 195 * i);
break;
case 4:
layout[i].setY(+layoutHeightTotal + mIconHeight / 5 - 220 * 3 + toolbarHeight * i);
triangle.setY(+layoutHeightTotal + mIconHeight / 5 - 250 * 2 + toolbarHeight * i);
break;
case 5:
layout[i].setY(+layoutHeightTotal + mIconHeight / 5 - 220 * 5 + toolbarHeight * i);
triangle.setY(+layoutHeightTotal + mIconHeight / 5 - 470 * 2 + toolbarHeight * i);
break;
default:
Log.e(TAG, "Invalid numbers of shortcuts! Max is 5");
break;
}
triangle.setRotation(0);
break;
default:
Log.e(TAG, "Resolution of screen not supported!");
break;
}
} else {
//Basso
positionInGrid = ((GridView) gridView).pointToPosition((int) currentXPosition, (int) currentYPosition);
positionInGrid /= gridSize.getColumnCount();
mIconHeight = Math.round(displayDensity * rowHeight) * positionInGrid + 1;
switch (maxXScreen){
case 720:
After Change
Log.e(TAG, "Invalid Row Height, it must be greater than 0");
return;
}
if(shortcuts.length == 0){
Log.e(TAG, "Shortcuts must be at least one!");
return;
}
USE_SHORTCUTS_FOR_LAUNCHER_3 = true;
getScreenDimension(activity);
int positionInGridDefault = positionInGrid;
if (layout != null || triangle != null)
clearAllLayout();
switch (maxXScreen) {
case 720:
DIM_WIDTH = 360;
DIM_HEIGHT = 90;
break;
case 1080:
DIM_WIDTH = 640;
DIM_HEIGHT = 150;
break;
case 1440:
DIM_WIDTH = 780;
DIM_HEIGHT = 200;
break;
default:
Log.e(TAG, "Resolution of screen not supported!");
break;
}
LayoutInflater inflater = LayoutInflater.from(activity.getApplicationContext());
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(DIM_WIDTH, DIM_HEIGHT);
RelativeLayout.LayoutParams paramsTriangle = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
//int mIconHeight = ((GridView) gridView).getColumnWidth();
int mIconHeight;
int mIconWidth = maxXScreen / gridSize.getColumnCount();
int dim = (positionInGrid) * mIconWidth;
int layoutHeightTotal = DIM_HEIGHT * shortcuts.length + PADDING;
triangle = (RelativeLayout) inflater.inflate(R.layout.shortcuts_triangle, null, false);
//Scale animation right to left
ScaleAnimation animationRightToLeft = new ScaleAnimation(0.0f, 1.0f, 1.0f, 1.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f);
animationRightToLeft.setDuration(200);
//Scale animation left to right
ScaleAnimation animationLeftToRight = new ScaleAnimation(0.0f, 1.0f, 1.0f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
animationLeftToRight.setDuration(200);
for (int i = 0; i < shortcuts.length; i++) {
layout[i] = (RelativeLayout) inflater.inflate(R.layout.shortcuts, null, false);
shortcuts[i].init(layout[i], optionLayoutStyle, activity, packageImage, this);
if ((dim + DIM_WIDTH) >= maxXScreen) {
//Destra
layout[i].setX(dim - DIM_WIDTH + (mIconWidth) - mIconWidth / 4);
triangle.setX((float) (dim + mIconWidth - mIconWidth / 1.5));
triangle.setRotation(180);
//Start Animation
layout[i].startAnimation(animationRightToLeft);
triangle.startAnimation(animationRightToLeft);
} else {
//Sinistra
layout[i].setX(dim + mIconWidth / 4);
triangle.setX((float) (dim + mIconWidth / 2));
triangle.setRotation(180);
//Start Animation
layout[i].startAnimation(animationLeftToRight);
triangle.startAnimation(animationLeftToRight);
}
if ((toolbarHeight = Utils.getToolbarHeight(activity)) >= 0) {
int maxYScreenWithToolbar = maxYScreen - toolbarHeight * 2;
positionInGrid = positionInGridDefault;
//positionInGrid /= gridSize.getColumnCount();
mIconHeight = rowHeight * (positionInGrid + 1);